﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>呷饭网</title>
    <link rel="stylesheet" type="text/css" href="./styles/mobile.css" />
    <link href="styles/jquery.ui.all.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="scripts/jquery.bgiframe-2.1.1.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.core.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.widget.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.mouse.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.button.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.draggable.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.position.js"></script>
    <script type="text/javascript" src="scripts/jquery.ui.dialog.js"></script>
    <link href="styles/flexy-menu.css" rel="stylesheet" />
    <script type="text/javascript" src="scripts/flexy-menu.js"></script>
    <script type="text/javascript" src="scripts/common.js"></script>

    <script type="text/javascript">
        var PageFlag;
        $(function () {
            $(".flexy-menu").flexymenu({ speed: 100 });
            getUserInfo();
            getListData("");
            PageFlag = getParameter("PageFlag");
            $('.goback').click(function () {
                if (PageFlag == "1") {
                    window.location.href = "./manager.html";
                }
                else {
                    window.location.href = "./login.html";
                }
            });
        });

        function getListData(flag) {
            getDishList(flag);
        }

        //获取酒店待传菜数据
        function getDishList(flag) {
            $("#tbllist").html("");

            if (flag == "Urgent") {
                $("#all").removeClass("active");
                $("#general").removeClass("active");
                $("#urgent").addClass("active");
            }
            else if (flag == "General") {
                $("#all").removeClass("active");
                $("#urgent").removeClass("active");
                $("#general").addClass("active");
            }
            else {
                $("#urgent").removeClass("active");
                $("#general").removeClass("active");
                $("#all").addClass("active");
            }

            var datas = "&flag=" + flag;
            var url = "CommonPage.aspx?opration=getDishList" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    if (data.Success) {
                        $("#Total").text(data.Total);
                        $(".tips")[0].style.display = "none";
                        for (var i = 0, str = ''; i < data.List.length; i++) {
                            str += "<tr><td class='l'>" + data.List[i].DishName + "<i style='color:red;font-size:14px;'>" + data.List[i].Copies + "</i></td><td class='c'>" + data.List[i].DineName + "<i>" + data.List[i].Dinecondition + "</i></td><td class='r'><a href='#' onclick=\"setDishState('" + data.List[i].OrderId + "','" + data.List[i].DishId + "','" + data.List[i].Num + "','" + data.List[i].IsDisplay + "');\">传菜</a></td></tr>";
                        }
                        $("#tbllist").html(str);
                    }
                    else {
                        if (data.Url != "") {
                            updateTip(data.Msg, true, "URL", data.Url);
                        }
                        else {
                            $("#Total").text("0");
                            $(".tips")[0].style.display = "";
                            $("#msgtip").text(data.Msg);
                        }
                    }
                }
            });
        }

        function setDishState(OrderId, DishId, Num, IsDisplay) {
            if (IsDisplay == "1" && parseInt(Num) > 1) {
                $("#iptNum").val(Num);
                $("#delCookbook").dialog("destroy");
                $("#delCookbook").dialog({
                    autoOpen: true,
                    resizable: false,
                    width: 270,
                    height: 140,
                    modal: true,
                    position: ["center", "center"],
                    buttons: {
                        "关 闭": function () {
                            $(this).dialog("close");
                        },
                        "确 定": function () {
                            if (parseInt($("#iptNum").val()) > parseInt(Num)) {
                                updateTip("输入的数量不能大于待传数量！", false, "", "");
                            }
                            else {
                                updateDishState(OrderId, DishId, $("#iptNum").val(), IsDisplay);
                            }
                        }
                    }
                });
            }
            else {
                updateDishState(OrderId, DishId, Num, IsDisplay);
            }
        }
        //传菜
        function updateDishState(OrderId, DishId, Num, IsDisplay) {
            var datas = "&OrderId=" + OrderId + "&DishId=" + DishId + "&Num=" + Num + "&IsDisplay=" + IsDisplay;
            var url = "CommonPage.aspx?opration=updateDishState" + datas;
            $.ajax({
                url: url,
                type: "post",
                dataType: 'json',
                success: function (data) {
                    $("#delCookbook").dialog("close");
                    if (data.Success) {
                        //updateTip(data.Msg, true, "Method", "");
                        getListData("");
                    }
                    else {
                        updateTip(data.Msg, false, "", "");
                    }
                }
            });
        }

        //减少菜品份数
        function subtract() {
            if (parseInt($("#iptNum").val()) > 1) {
                $("#iptNum").val(parseInt($("#iptNum").val()) - 1);
            }
        }
        //增加菜品份数
        function add() {
            $("#iptNum").val(parseInt($("#iptNum").val()) + 1);
        }
    </script>
</head>

<body>
    <div class="wrapall">
        <table class="topbar">
            <tr>
                <td class="l"><a class="goback">返回</a></td>
                <td class="c" id="H_Name"></td>
                <td class="r" align="right">
                    <ul class="flexy-menu">
                        <li id="lilist">
                        </li>
                    </ul>
                </td>
            </tr>
        </table>
        <p class="textinfo">共有<b id="Total">0</b>道菜等待传</p>
        <table class="tab1">
            <tr>
                <td class="active" id="all"><a href="#" onclick="getDishList('');">全部</a></td>
                <td id="urgent"><a href="#" onclick="getDishList('Urgent');">加急</a></td>
                <td id="general"><a href="#" onclick="getDishList('General');">普通</a></td>
            </tr>
        </table>
        <table class="tbllist" id="tbllist">
        </table>
        <span class="tips" style="display: none;"><i></i><b id="msgtip"></b>

        </span>
        <br />
    </div>
    <div id="dialog" title="提示信息" style="text-align: center; vertical-align: middle;">
        <p class="dialogTip"></p>
    </div>
    <div id="delCookbook" title="待传数量" style="display:none;">
        <table style="border:0px;">
            <tr>
                <br />
                <td style="vertical-align:bottom;width:55%;">待传数量</td>
                <td align="left"><img src='images/jian.png' onclick="subtract();"/><input type="text" id="iptNum" readonly="readonly" value="0" style="width:40px;vertical-align:top; text-align:center;"/><img src='images/jia.png' onclick="add();"/></td>
            </tr>
        </table>
    </div>
</body>
</html>
